/**
 * @modulename Convertor
 * @description The Convertor is a utility class to convert Binary to Hex and 
 * Hex to Binary
 * @callsequence Call the Convertor as a static utility class
 * @inparam none
 * @outparam none
 * @errorstested none
 * @errorsgenerated none
 * @author Travis Casper
 * @createdate 11/20/09
 * @modlog <p>
 *         <ul>
 *         Who/When/Why
 *         <li>Travis 11/24/09 Created.
 *         </ul><p>
 *         Coding Standards Met: "Signed Code Leader(Jaron)"
 *         <p>
 *         Testing Standards Met: "Signed Test Leader(Jamie)"
 */
public final class Convertor {
	public Convertor() {}
	
	/**
	 * @modulename hexToBinary
	 * @description A method that will convert a hex character to a String of 4
	 * Binary Digits.
	 * @callsequence <code>Convertor.hexToBinary(hexChar);</code>
	 * @inparam char - A Hex Character that will be converted to Binary
	 * @outparam String - Four Binary Digits that represent the Binary value for the
	 * character given as an input parameter.
	 * @errorstested none
	 * @errorsgenerated none
	 * @author Travis Casper
	 * @createdate 11/20/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Travis 11/24/09 Created.
	 *         </ul><p>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static String hexToBinary(char hexChar) {
		String hexDigit = Character.toString(hexChar);
		if (hexDigit.equalsIgnoreCase("0")) {
			return "0000";
		} else if (hexDigit.equalsIgnoreCase("1")) {
			return "0001";
		} else if (hexDigit.equalsIgnoreCase("2")) {
			return "0010";
		} else if (hexDigit.equalsIgnoreCase("3")) {
			return "0011";
		} else if (hexDigit.equalsIgnoreCase("4")) {
			return "0100";
		} else if (hexDigit.equalsIgnoreCase("5")) {
			return "0101";
		} else if (hexDigit.equalsIgnoreCase("6")) {
			return "0110";
		} else if (hexDigit.equalsIgnoreCase("7")) {
			return "0111";
		} else if (hexDigit.equalsIgnoreCase("8")) {
			return "1000";
		} else if (hexDigit.equalsIgnoreCase("9")) {
			return "1001";
		} else if (hexDigit.equalsIgnoreCase("A")) {
			return "1010";
		} else if (hexDigit.equalsIgnoreCase("B")) {
			return "1011";
		} else if (hexDigit.equalsIgnoreCase("C")) {
			return "1100";
		} else if (hexDigit.equalsIgnoreCase("D")) {
			return "1101";
		} else if (hexDigit.equalsIgnoreCase("E")) {
			return "1110";
		} else if (hexDigit.equalsIgnoreCase("F")) {
			return "1111";
		} else {
			return "error";
		}
	}

	/**
	 * @modulename binaryToHex
	 * @description A method that will convert a String of 4 Binary digits to a
	 * single-character String representing the Hex Value of the input.
	 * Binary Digits.
	 * @callsequence <code>Convertor.binaryToHex(fourBinary);</code>
	 * @inparam String - Four Binary Digits that represent the Binary value for the
	 * character given as an input parameter.
	 * @outparam char - A Hex Character that will be converted to Binary
	 * @errorstested none
	 * @errorsgenerated none
	 * @author Travis Casper
	 * @createdate 11/20/09
	 * @modlog <p>
	 *         <ul>
	 *         Who/When/Why
	 *         <li>Travis 11/24/09 Created.
	 *         </ul><p>
	 *         Coding Standards Met: "Signed Code Leader(Jaron)"
	 *         <p>
	 *         Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	public static String binaryToHex(String fourBinary) {
		if (fourBinary.equalsIgnoreCase("0000")) {
			return "0";
		} else if (fourBinary.equalsIgnoreCase("0001")) {
			return "1";
		} else if (fourBinary.equalsIgnoreCase("0010")) {
			return "2";
		} else if (fourBinary.equalsIgnoreCase("0011")) {
			return "3";
		} else if (fourBinary.equalsIgnoreCase("0100")) {
			return "4";
		} else if (fourBinary.equalsIgnoreCase("0101")) {
			return "5";
		} else if (fourBinary.equalsIgnoreCase("0110")) {
			return "6";
		} else if (fourBinary.equalsIgnoreCase("0111")) {
			return "7";
		} else if (fourBinary.equalsIgnoreCase("1000")) {
			return "8";
		} else if (fourBinary.equalsIgnoreCase("1001")) {
			return "9";
		} else if (fourBinary.equalsIgnoreCase("1010")) {
			return "A";
		} else if (fourBinary.equalsIgnoreCase("1011")) {
			return "B";
		} else if (fourBinary.equalsIgnoreCase("1100")) {
			return "C";
		} else if (fourBinary.equalsIgnoreCase("1101")) {
			return "D";
		} else if (fourBinary.equalsIgnoreCase("1110")) {
			return "E";
		} else if (fourBinary.equalsIgnoreCase("1111")) {
			return "F";
		} else {
			return "error";
		}
	}
}
